﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Enlightener.Engine.Deobfuscator.Tasks.Common;
using Enlightener.Engine.Structs__Enums___Interfaces;
using Enlightener.Engine.Utils;
using Mono.Cecil;

namespace Enlightener.Engine.Deobfuscator
{
    class MainDeobfuscator : IDeobfuscator
    {
        public MainDeobfuscator(AssemblyDefinition asmDef)
            : base(asmDef)
        {
        }

        public override void CreateTaskQueue()
        {
            switch(DeobfuscatorContext.Signature.InternalVersion)
            {
                case InternalVersion.V1_7:
                    TaskQueue.Add(new Tasks.Common.MethodCleaner(AsmDef));
                    //TaskQueue.Add(new Tasks._1_7.ResourceDecryptor(AsmDef));
                    TaskQueue.Add(new Tasks._1_7.ConstantsDecryptor(AsmDef));
                    TaskQueue.Add(new Tasks._1_7.StackUnderflowCleaner(AsmDef));
                    TaskQueue.Add(new Tasks.Common.WatermarkRemover(AsmDef));
                    TaskQueue.Add(new Tasks._1_7.AntiDump(AsmDef));
                    TaskQueue.Add(new Tasks._1_7.AntiDebug(AsmDef));
                    TaskQueue.Add(new Tasks._1_7.AntiILDasm(AsmDef));
                    TaskQueue.Add(new Tasks.Common.AssemblyStripper(AsmDef));
                    TaskQueue.Add(new Tasks.Common.Renamer(AsmDef, new RenamingScheme(true) {Resources = false}));
                    break;

                case InternalVersion.V1_8:
                    TaskQueue.Add(new Tasks._1_8.ConstantsDecryptor(AsmDef));
                    break;
                    
                case InternalVersion.V1_9:
                    break;
            }

            Deobfuscate();
        }
    }
}
